package com.hmkx.rest;


import com.alibaba.druid.support.logging.LogFactory;
import com.hmkx.model.Articles;
import com.hmkx.service.ArticleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class ArticleController {

    Logger log = LoggerFactory.getLogger(ArticleController.class);

    @Resource
    private ArticleService articleServiceImpl;

    @GetMapping("/getArticle")
    public String getArticleById(HttpServletRequest request, HttpServletResponse response){
        String id = request.getParameter("id");
        log.info(id);
        //连接数据库freezing(默认数据库）
        Articles article = articleServiceImpl.getArticleById(Integer.parseInt(id));
        //连接ucenter
        int res = articleServiceImpl.updateByPrimaryKey(Integer.parseInt(id));
        log.info(res+"");

        log.info(article.getTitle());
        return  "111";

    }
}
